<template>
	<view class="console-cell">
		<view class="time" v-if="story.create_time">
			{{formatTime(story.create_time)}}
		</view>
		<view class="desc">
			{{story.desc}}
		</view>
	</view>
</template>

<script>
	export default {
		name:"console-cell",
		props: {
			story: {
				type: Object,
				default: null
			}
		},
		data() {
			return {
				
			};
		},
		methods: {
			formatTime(timestamp) {
				 // 1. 将秒级时间戳转为毫秒（因为JS的Date需要毫秒）
				const date = new Date(timestamp * 1000);

				// 2. 获取时、分、秒，并补零
				const hours = String(date.getHours()).padStart(2, '0');
				const minutes = String(date.getMinutes()).padStart(2, '0');
				const seconds = String(date.getSeconds()).padStart(2, '0');

				// 3. 组合成 HH:MM:SS 格式
				return `${hours}:${minutes}:${seconds}`;
			}
		}
	}
</script>

<style scoped>
	
	.console-cell {
		display: flex;
		align-items: start;
		font-size: 14px;
		padding: 2px 3px;
		color: wheat;
	}
	
	.console-cell:hover {
		cursor: pointer;
		background-color: #363643;
	}
	
	.time {
		margin-right: 5px;
	}
	
	.desc {
		margin-top: -1px;
	}

</style>